<div class="widthFullScreen comHeader">
	<div class="wdSafe" style="overflow: hidden;">
		<div class="pull-left cust_tel">全国客服电话：173-4303-0506</div>
		<a href="/" class="pull-left return_back">返回首页</a>
		<ul class="pull-right list_header_com">
			<li>
				<a href="javascript:;">奇快企服欢迎,&nbsp;<span id="userNameBox">admin</span>&nbsp;回来</a>
			</li>
			<li>
				<a href="/users/index">查看<span class="colorMain">我的订单</span></a>
			</li>
			<li onclick="loginOut()">
				<a href="javascript:;">退出</a>
			</li>
		</ul>
	</div>
</div>

<div class="widthFullScreen userHeader">
	<div class="wdSafe">
		<img class="user_logo pull-left" src="https://img.qikuai100.com/logo.png" alt="" />
		<p class="left_border pull-left">用户中心</p>
	</div>
</div>

<script>
	var baseUrl = 'https://api.qikuai100.com/',
	    uid = localStorage.getItem("uid");
	$(function() {
		initLogin();
	});
	// 登录验证
	function initLogin() {
	    $.ajax({
	        type: "POST",
	        url: baseUrl + "api/auth/checklogin",
	        data: {
	            "uid": uid
	        },
	        success: function(result) {
	            if (result.ret == 0) {
	            	if(result.data.status == '1'){
	            		var name = localStorage.getItem("name");
	            		$('#userNameBox').html(name);
	            	}else{
	            		layer.msg(result.msg);
		            	setTimeout(function(){
		            		window.location.href = '/user/login';
		            	}, 1000);
	            	}
	            }else{
	            	layer.msg(result.msg);
	            	setTimeout(function(){
	            		window.location.href = '/user/login';
	            	}, 1000);
	            }
	        }
	    });
	}

	/**
	* 退出
	*/
	function loginOut(){
		$.ajax({
			type: "POST",
			url: baseUrl + "api/auth/logout",
			data: {
				"uid": uid
			},
			success: function(result) {
				if(result.ret == 0) {
					localStorage.clear();
					layer.msg("退出登录成功");
					setTimeout(function(){
						window.location.href = '/index/index';
					}, 1000);
				}else{
					layer.msg(result.res_info);
				}
			}
		});
	}
</script>